def prosto(n):
    b = 2
    while n % b != 0:
        b += 1
    return b == n


a = input().split()
num = {'zero': '0',
       'one': '1',
       'two': '2',
       'three': '3',
       'four': '4',
       'five': '5',
       'six': '6',
       'seven': '7',
       'eight': '8',
       'nine': '9'}
r = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
flag = True
for i in a:
    if i not in r:
        print('Wrong input')
        flag = False
        break
if flag is True:
    fnum = ''
    for i in a:
        fnum += num.get(i)
    fnum = int(fnum)
    if len(str(fnum)) != 3 or len(a) != 3:
        print('Wrong input')
    else:
        p = fnum
        m = fnum
        while prosto(p) is False:
            p += 1
        while prosto(m) is False:
            m -= 1
        if p - fnum <= fnum - m:
            print(p)
        else:
            print(m)